Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
emptyfunction
Advanced tools
The module exports nothing but an empty function/closure.
npm install emptyfunction
Get the empty closure from the module
var emptyFunction = require('emptyfunction');
Now use the function whenever there is an optional closure within your code.
function example(cb) {
if (!cb) cb = emptyFunction
for (var i = 0; i < 1337; i++) cb()
}
Sometimes you might need to verify whether the closure is an empty function.
If you have access to the emptyFunction object you can do a strict comparison.
this.someFunction === emptyFunction
If not, a more hacky solution is to use the name of the function:
this.someFunction.name === 'emptyFunction'
A simple function to check whether we're dealing with an actual closure:
function isClosure(cb) {
return (cb && cb !== emptyFunction) ? true: false
}
A simple function to make assigning closures easier:
function setClosure(cb) {
return (isClosure(cb)) ? cb : emptyFunction
}
// Usage:
var myClosure = setClosure(cb)
MIT
FAQs
An empty function.
We found that emptyfunction demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.